home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / extra_2 / nadir11.zip / BKUP.N < prev    next >
Text File  |  1995-11-08  |  4KB  |  98 lines

  1. Define DosBackupRestore(type) {
  2.     if (type == "b")
  3.         title = "File Backup";
  4.     else
  5.         title = "File Restore";
  6.  
  7.     scr = SdCreate(,-2, -2, 15, 64, title);
  8.     SdPrompt(scr, 1, 3, "Diskette Device :");
  9.     SdRadio (scr, "deva", 1, 1, 21,  6, &parm^bkup^dev, "A:", "a");
  10.     SdRadio (scr, "devb", 1, 1, 30,  6, &parm^bkup^dev, "B:", "b");
  11.  
  12.     SdPrompt(scr, 3, 3, "Data Directory  :");
  13.     SdString(scr, "dir", 1,  3, 21, 40, &parm^bkup^dir);
  14.     SdPrompt(scr, 4, 43, "(\\ is added)");
  15.  
  16.     SdPrompt(scr, 6, 3, "Filename        :");
  17.     SdString(scr, "file", 1,  6, 21, 20, &parm^bkup^file);
  18.     SdPrompt(scr, 6, 43, "(Wildcard allowed)");
  19.  
  20.     if (type == "b") {
  21.         SdPrompt(scr,  9, 3, "Remember : BACKUP will copy the specified Filename(s)");
  22.         SdPrompt(scr, 10,14, "FROM the Data Directory TO the Diskette Device");
  23.     }
  24.     else {
  25.         SdPrompt(scr,  9, 3, "Remember : RESTORE will copy the specified Filename(s)");
  26.         SdPrompt(scr, 10,14, "FROM the Diskette Device TO the Data Directory");
  27.     }
  28.     SdPrompt(scr, 11,14, " ");  // so that previous line isnt highlighted
  29.  
  30.     SdButton(scr, "", 1,    13, 21, 10, "OK",     "", 1);
  31.     SdButton(scr, "", 1,    13, 34, 10, "Cancel", "", 2);
  32.  
  33.     while (1) {
  34.         if (SdEdit(scr, cursor) == 1) {
  35.             if (!SdFieldGet(scr, cursor = "file")) {
  36.                 MsgWait("", "You must enter something in filename (eg *.dat)");
  37.                 continue;
  38.             }
  39.             if (!SdFieldGet(scr, cursor = "deva") && !SdFieldGet(scr, "devb")) {
  40.                 MsgWait("", "You must choose a Backup Device");
  41.                 continue;
  42.             }
  43.  
  44.             SdUpdate(scr);
  45.             if (type == "b")
  46.                 SystemRestart("compause backup " . parm^bkup^dir . "\\" .
  47.                               parm^bkup^file . " " . parm^bkup^dev . ":");
  48.             else
  49.                 SystemRestart("compause restore " . parm^bkup^dev . ": " . 
  50.                        parm^bkup^dir . "\\" . parm^bkup^file);
  51.         }
  52.         break;
  53.     }
  54.     SdDestroy(scr);
  55. }
  56. Define SysFileRecover(name) {
  57.     check = 1;
  58.     while (1) {
  59.         scr = SdCreate(,-1, -1, 18, 72, "System Startup");
  60.         SdPrompt(scr, 2,  9, StrCat(name, " has been improperly closed"));
  61.         SdButton(scr, "", 1,     5,  9, 20, "Restore Files", "r", 30);
  62.         SdButton(scr, "", check, 7,  9, 20, "Check File", "c", 31);
  63.         SdButton(scr, "", 1,     9,  9, 20, "Rebuild File", "b", 32);
  64.         SdButton(scr, "", 1,    16, 55, 10, "Cancel", "", 2);
  65.  
  66.         cmd = SdEdit(scr);
  67.         SdDestroy(scr);
  68.  
  69.         if (cmd == 30)
  70.             DosBackupRestore("r");
  71.         else if (cmd == 31) {
  72.             rc = Spawn("stu check -c " . name);
  73.             if (rc == 1) {
  74.                 MsgWait("System Startup", 
  75.                         "Errors were found in " . name .
  76.                         ".\nThe file has been left in its\noriginal (improperly closed) state."
  77.                         );
  78.                 check = 0;
  79.                 val = "";
  80.                 continue;
  81.             }
  82.             Signal("");             /* will restart and try another time */
  83.         }
  84.         else if (cmd == 32)
  85.             SpawnRestart("stu rebuild -c " . name);
  86.         else if (cmd == 2 || cmd == 3)
  87.             break;
  88.     }
  89.     Exit("System stopped at users request");
  90. }
  91.  
  92. Define SysLockQuery(name) {
  93.     if (MsgYesNo("System File Locking", name . " cannot be locked\n\
  94. \n\
  95. Do you wish to retry ?") != 1)
  96.         return 1;
  97. }
  98.